<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <script>
    // 数组去重法
    // 1. 双循环去重
    {
      const arr = [1, 3, 3, 3, 5, 4, 3, 4, 6, 5]
      for (let i = 0; i < arr.length - 1; i++) {
        const item = arr[i];
        for (let j = i + 1; j < arr.length; j++) {
          if (item === arr[j]) {
            arr.splice(j, 1)
            j--;
          }
        }
      }
      console.log(arr);
    }
    // 2. 对象去重
    {
      const arr = [1, 3, 3, 3, 5, 4, 3, 4, 6, 5]
      const obj = {}
      for (let i = 0; i < arr.length; i++) {
        const item = arr[i];
        if (obj[item] !== undefined) {
          arr[i] = arr[arr.length - 1]
          arr.length--
          i--
        } else {
          obj[item] = item
        }
      }
      console.log(arr);
    }
    {
      // charAt charCodeAt
      const str = 'abcdefg'
      console.log(str.charAt(2));
      console.log(str.charCodeAt(2));
      // substr substring
      console.log(str.substr(1, 2)); // 从m开始截n个
      console.log(str.substring(1, 3)); // [m,n) 截取
      // toLowerCase toUpperCase
      const up = `ABCDE`
      const toLow = up.toLowerCase()
      const toUp = toLow.toUpperCase()
      console.log(up, toLow, toUp);
      // indexOf lastIndexOf 同 array
      // split
      const str3 = `i am a font end engneer`
      const arr = str3.split(' ')
      console.log(arr);
    }
  </script>
</body>

</html>